home *** CD-ROM | disk | FTP | other *** search
/ Chip: 2001 Haziran / CHIP Haziran2001.iso / prog / haziran / 19 / setup.exe / data.z / ask_data.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-04-11  |  2.7 KB  |  84 lines

  1. VERSION 5.00
  2. Begin VB.Form ask_data 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Insert Data"
  5.    ClientHeight    =   1296
  6.    ClientLeft      =   36
  7.    ClientTop       =   264
  8.    ClientWidth     =   1824
  9.    Icon            =   "ask_data.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   1296
  14.    ScaleWidth      =   1824
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin VB.CommandButton Write_Button 
  17.       Caption         =   "Write"
  18.       Default         =   -1  'True
  19.       Height          =   252
  20.       Left            =   480
  21.       TabIndex        =   1
  22.       Top             =   840
  23.       Width           =   852
  24.    End
  25.    Begin VB.TextBox DataText 
  26.       Alignment       =   2  'Center
  27.       Height          =   288
  28.       Left            =   480
  29.       MaxLength       =   2
  30.       TabIndex        =   0
  31.       Text            =   "00"
  32.       Top             =   240
  33.       Width           =   852
  34.    End
  35. Attribute VB_Name = "ask_data"
  36. Attribute VB_GlobalNameSpace = False
  37. Attribute VB_Creatable = False
  38. Attribute VB_PredeclaredId = True
  39. Attribute VB_Exposed = False
  40. ' File - ask_data.frm
  41. ' This application reads and writes data to the Parallel Port, and is
  42. ' controlled via a graphical user interface - pp_gui.frm
  43. ' The Parallel Port is accessed directly on the motherboard, using
  44. ' WinDriver functions.
  45. Private Sub Form_Load()
  46.     ask_data.DataText = Hex(g_Data)
  47.     ask_data.DataText.Refresh
  48.     ask_data.DataText.SelStart = 0
  49.     ask_data.DataText.SelLength = 2
  50. End Sub
  51. Private Sub Write_Button_Click()
  52.     If (ask_data.DataText = "") Then
  53.         MsgBox "Data is empty.", vbExclamation + vbOKOnly, "Error"
  54.         GoTo error
  55.     End If
  56.     If (Not IsHexText(ask_data.DataText)) Then
  57.         MsgBox "The value you entered is not a valid Hexadesimal value." & Chr$(13) & _
  58.             "Enter a new value.", vbExclamation + vbOKOnly, "Error"
  59.         GoTo error
  60.     End If
  61.     g_Data = Val("&H" & ask_data.DataText)
  62.     Unload ask_data
  63.     GoTo finish
  64. error:
  65.     ask_data.DataText = Hex(g_Data)
  66.     ask_data.DataText.Refresh
  67.     ask_data.DataText.SetFocus
  68.     ask_data.DataText.SelStart = 0
  69.     ask_data.DataText.SelLength = 2
  70. finish:
  71. End Sub
  72. Private Function IsHexText(str As String) As Boolean
  73.     Dim str0, str1 As String
  74.     str0 = Left(str, 1)
  75.     str1 = Right(str, 1)
  76.     If ((Val("&H" & str0) = 0) And (Asc(str0) <> 48)) _
  77.         Or _
  78.         ((Val("&H" & str1) = 0) And (Asc(str1) <> 48)) Then
  79.         IsHexText = False
  80.     Else
  81.         IsHexText = True
  82.     End If
  83. End Function
  84.